<template>
  <section class="my-download">
    <div class="top flex">
      <img
        :src="info.frontImgUrl"
        alt
      />
      <div class="">
        <div class="title">{{info.productName}}</div>
        <div class="desc">{{info.productTitle}}</div>
        <div class="desc">{{info.packageSize}}</div>
        <div class="tag">{{info.className}}</div>
      </div>
      <button @click="downLoad(info.dowloadUrl)">下载</button>
    </div>
    <div class="section">
      <div class="title">应用截图</div>
      <scroll-view
        scroll-x
        class="scroll-view"
      >
        <img
          mode="scaleToFill"
          v-for="img in info.imgList"
          :key="img.id"
          :src="img.imageUrl"
        />
      </scroll-view>
    </div>
    <div class="section">
      <div class="title">应用介绍</div>
      <div
        class="desc"
        v-html="info.productDtl"
      >
      </div>
    </div>
    <button
      class="download"
      @click="downLoad(info.dowloadUrl)"
    >下载</button>
  </section>
</template>
<script>
export default {
  data() {
    return {
      productId: '',
      info: ''
    };
  },
  onLoad(e) {
    this.productId = e.id ? e.id : 1;
    this.selectProductDetail();
  },
  methods: {
    downLoad(e) {
      wx.setClipboardData({
        data: e,
        success(res) {
          wx.showToast({
            title: '下载地址已复制，请至浏览器进行下载',
            icon: 'none',
            duration: 2000,
            mask: false,
          });
        }
      });
    },
    //详情
    selectProductDetail() {
      this.$api.selectProductDetail({ 'productId': this.productId }).then(res => {
        res.data.product.productDtl = res.data.product.productDtl.replace(/<img/gi, '<img style="width:100%;height:auto;display:block" ');
        res.data.product.productDtl = res.data.product.productDtl.replace(/<p/gi, '<p style="padding:15px" ');
        // console.log(result);
        this.info = res.data.product;
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.my-download {
  .top {
    position: relative;
    padding: 15px;
    img {
      width: 84px;
      height: 84px;
      border-radius: 8px;
      margin-right: 15px;
    }
    .title {
      font-size: 18px;
      font-family: PingFang;
      font-weight: bold;
      color: rgba(51, 51, 51, 1);
      margin-bottom: 9px;
    }
    .desc {
      font-size: 12px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: rgba(161, 164, 172, 1);
      margin-bottom: 9px;
    }
    .tag {
      font-size: 12px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: rgba(161, 164, 172, 1);
      padding: 3px 6px;
      border-radius: 5px;
      border: 1px solid rgba(59, 184, 253, 1);
      display: inline-block;
    }
    button {
      width: 55px;
      height: 24px;
      background: rgba(59, 184, 253, 1);
      border-radius: 12px;
      position: absolute;
      right: 15px;
      bottom: 15px;
      font-size: 12px;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: rgba(255, 255, 255, 1);
      padding: 0;
      margin: 0;
      line-height: 24px;
    }
  }
  .section {
    .scroll-view {
      height: 370px;
      white-space: nowrap;
      display: flex;
    }
    .title {
      font-size: 18px;
      font-family: PingFang;
      font-weight: bold;
      color: rgba(51, 51, 51, 1);
      line-height: 12px;
      padding: 15px;
    }
    img {
      &:first-child{
          margin-left:15px;
      }
      width: 195px;
      height: 347px;
      border-radius: 10px;
      margin-right: 15px;
      display: inline-block;
    }
    .desc {
      img {
        width: 100% !important;
      }
      font-size: 12px;
      font-family: PingFang;
      font-weight: 500;
      color: rgba(46, 46, 46, 1);
      line-height: 21px;
      padding: 15px;
      margin:15px;
    }
    .flex {
      flex-wrap: nowrap;
    }
  }
  .download {
    width: 345px;
    height: 44px;
    background: rgba(59, 184, 253, 1);
    border-radius: 5px;
    font-size: 15px;
    font-family: PingFang;
    font-weight: 500;
    color: rgba(255, 255, 255, 1);
    line-height: 44px;
    margin: 15px;
  }
}
</style>
<style lang="scss">
.van-tabs__line {
  color: #3bb8fd;
}
</style>
